fstats_bootstrap Module



Interfaces

interface

  • public subroutine bootstrap_resampling_routine(x, xn)

    Defines the signature of a subroutine used to compute a resampling of data for bootstrapping purposes.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in), dimension(:) :: x

    The N-element array to resample.

    real(kind=real64), intent(out), dimension(size(x)) :: xn

    An N-element array where the resampled data set will be written.

interface

  • public function bootstrap_statistic_routine(x) result(rst)

    Defines the signature of a function for computing the desired bootstrap statistic.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in), dimension(:) :: x

    The array of data to analyze.

    Return Value real(kind=real64)

    The resulting statistic.


Derived Types

type, public ::  bootstrap_statistics

A collection of statistics resulting from the bootstrap process.

Components

Type Visibility Attributes Name Initial
real(kind=real64), public :: bias

The bias in the statistic.

real(kind=real64), public :: lower_confidence_interval

The lower confidence limit on the statistic.

real(kind=real64), public, allocatable, dimension(:) :: population

The bootstrap statistic replicates, excluding the observed statistic.

real(kind=real64), public :: standard_error

The standard error.

real(kind=real64), public :: statistic_value

The value of the statistic of interest.

real(kind=real64), public :: upper_confidence_interval

The upper confidence limit on the statistic.


Functions

public function bootstrap(stat, x, method, nsamples, alpha) result(rst)

Performs a bootstrap calculation on the supplied data set for the given statistic. The default implementation utlizes a random resampling with replacement. Other resampling methods may be defined by specifying an appropriate routine by means of the method input. The module provides another option, random_resample, which is a parametric Gaussian bootstrap based on the sample mean and standard deviation. It assumes normally distributed observations. The confidence limits are percentile intervals calculated from the bootstrap replicates.

Arguments

Type IntentOptional Attributes Name
procedure(bootstrap_statistic_routine), intent(in), pointer :: stat

The routine used to compute the desired statistic.

real(kind=real64), intent(in), dimension(:) :: x

The N-element data set.

procedure(bootstrap_resampling_routine), intent(in), optional, pointer :: method

An optional pointer to the method to use for resampling of the data. If no method is supplied, a random resampling is utilized.

integer(kind=int32), intent(in), optional :: nsamples

An optional input, that if supplied, specifies the number of bootstrap replicates to generate. The default is 10 000.

real(kind=real64), intent(in), optional :: alpha

An optional input, that if supplied, defines the significance level to use for the analysis. The default is 0.05.

Return Value type(bootstrap_statistics)

The resulting bootstrap_statistics type containing the confidence intervals, bias, standard error, etc. for the analyzed statistic.


Subroutines

public subroutine random_resample(x, xn)

Parametric Gaussian resampling using the sample mean and standard deviation. This assumes the observations are normally distributed; it is not the nonparametric bootstrap.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in), dimension(:) :: x

The N-element array to resample.

real(kind=real64), intent(out), dimension(size(x)) :: xn

An N-element array where the resampled data set will be written.

public subroutine random_resample_circular_blocks(x, xn)

Resamples a time series using a circular moving-block bootstrap. The block length is floor(sqrt(n)), with a minimum of two when possible. Define a custom callback to use a domain-specific block length.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in), dimension(:) :: x

The N-element time series.

real(kind=real64), intent(out), dimension(size(x)) :: xn

The resampled series, assembled from circular blocks.

public subroutine random_resample_clusters(x, xn)

Resamples balanced clusters with replacement. The input stores contiguous records as [cluster_id, value], with every cluster having the same number of records. The statistic routine should use the value fields and ignore the cluster identifiers.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in), dimension(:) :: x

An even-length array of contiguous cluster-id/value records.

real(kind=real64), intent(out), dimension(size(x)) :: xn

The resampled records in the same layout.

public subroutine random_resample_paired(x, xn)

Resamples paired observations with replacement. The input stores each pair as adjacent values: [x1, y1, x2, y2, ...].

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in), dimension(:) :: x

An even-length array of interleaved paired observations.

real(kind=real64), intent(out), dimension(size(x)) :: xn

The resampled pairs in the same interleaved layout.

public subroutine random_resample_with_replacement(x, xn)

Random resampling with replacement from the supplied sample.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in), dimension(:) :: x

The N-element array to resample.

real(kind=real64), intent(out), dimension(size(x)) :: xn

An N-element array where the resampled data set will be written.